* Create EGP social class measures using past census occupation codes.
*
* Uses IPUMS occupation crosswalks to create 2010 codes so that the 
* Morgan (2017) EGP crosswalk can be used to categorize occupations
* into social class categories.
*
* This is required when using survey data without 2010 census codes.
*
* Only 1980, 1990, and 2000 codes are converted to the 2010 codes used
* by Morgan.


set more off

import excel "~/Dropbox/Class/Data.Analysis/ANES_CDF/occ_crosswalks.xlsx", sheet("occ2010") firstrow clear


* Clean up the IPUMS crosswalk.
foreach v of varlist occ2000 ACS20002002 ACS20032009 ACS2010 {
	replace `v' = "" if `v' == "BBB" | `v' == "BBBB"
}

destring occ2000 ACS20002002 ACS20032009 ACS2010, replace

rename ACS2010 occ10

replace occ10 = occ10[_n-1] if occ10 == .

keep Occupationcategorydescription occ1980 occ1990 occ2000 occ10

save "occ_crosswalks.dta", replace

preserve
drop if occ1980 == .
keep occ1980 occ10
save "occ_crosswalk_1980.dta", replace
restore

preserve
drop if occ1990 == .
keep occ1990 occ10
save "occ_crosswalk_1990.dta", replace
restore

drop if occ2000 == .
keep occ2000 occ10
save "occ_crosswalk_2000.dta", replace

clear

